package com.kfm.pm.thread;

import java.util.Stack;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class RunnableDemo {

    public static void main(String[] args) {
        Thread thread = new Thread(new MyRunnable3());
        Thread thread1 = new MyThread2();
        thread.start(); // run()
        thread1.start(); // run()
        FutureTask<Integer> task = new FutureTask<>(new MyCallable2());
        Thread thread2 = new Thread(task); // target.run()
        thread2.start(); // run() --> target.run()  task.run()  --> call.call()  值存储到 outcome
        try {
            task.get(); // 从 outcome 中取出来值
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
}



class MyCallable2 implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        return null;
    }
}

class MyThread2 extends Thread {
    public void run() {

    }
}

class MyRunnable3 implements  Runnable {

    @Override
    public void run() {

    }
}
